services:
  user-service-db:
    image: postgres
    container_name: user-service-db
    restart: unless-stopped
    env_file: ./.env
    environment:
      - POSTGRES_USER=$POSTGRES_USER
      - POSTGRES_PASSWORD=$POSTGRES_ROOT_PASSWORD
      - POSTGRES_DB=$POSTGRES_DATABASE
    ports:
      - $POSTGRES_LOCAL_PORT:$POSTGRES_DOCKER_PORT
    networks:
      - user-service-network
  app:
    depends_on:
      - user-service-db
    build: .
    restart: on-failure
    env_file: ./.env
    environment:
      - USER_SERVICE_SERVER_PORT=$SPRING_DOCKER_PORT
      - DATABASE_NAME=jdbc:postgresql://user-service-db:$POSTGRES_DOCKER_PORT/$POSTGRES_DATABASE
      - DATABASE_USER=$POSTGRES_USER
      - DATABASE_USER_PASSWORD=$POSTGRES_ROOT_PASSWORD
      - RSA_PRIVATE_KEY=$RSA_PRIVATE_KEY
      - RSA_PUBLIC_KEY=$RSA_PUBLIC_KEY
    stdin_open: true
    tty: true
    ports:
      - $SPRING_LOCAL_PORT:$SPRING_DOCKER_PORT
    networks:
      - user-service-network
networks:
  user-service-network:
    driver: bridge